﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;


namespace VOL.Smartmanufacturing.Infrastructure
{
    public interface IBaseRepository<T> where T : class
    {
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> AddAsync(T entity);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> UpdateAsync(T entity);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> Remove(T entity);
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        Task<int> AddRange(IEnumerable<T> entities);
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        Task<int> UpdRange(IEnumerable<T> entities);
        /// <summary>
        /// 显示
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 带条件显示全部数据
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        IQueryable<T> GetAll(Expression<Func<T,bool>> expression);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        Task<int> DelAll(Expression<Func<T,bool>> expression);
        /// <summary>
        /// 根据ID异步查找实体
        /// </summary>
        /// <param name="id">实体ID</param>
        /// <returns>返回查找到的实体，如果未找到则返回null</returns>
        Task<T> FindAsync(int id);
        

    }
}
